<template>
  <div class="risk">
    <van-search class="info_search" v-model="value" placeholder="搜索" />
    <van-list
      style="margin-top: 10px"
      :finished="finished"
      v-model="loading"
      finished-text="没有更多了"
    >
      <van-radio-group @change="handleChange" v-model="result">
        <van-cell v-for="(item, index) in list" :key="index">
          <div class="risk_item_radio">
            <div>
              <div class="mb-10">{{ item.OrgName }}</div>
              <div>{{ item.OrgFullName }}</div>
            </div>
            <van-radio :name="item.OrgCode"></van-radio>
          </div>
        </van-cell>
      </van-radio-group>
    </van-list>

    <!-- <div class="risk_item_radio">
            <div>
                <div class="mb-10">所有部门</div>
                <div>所有部门</div>
            </div>
       <van-checkbox name="{a:ggg,c:xxx}"></van-checkbox>
        </div>
        <div class="risk_item_radio">
            <div>
                <div class="mb-10">所有部门</div>
                <div>所有部门</div>
            </div>
         <van-checkbox name="{a:ggg,c:xxx}"></van-checkbox>
        </div> -->
  </div>
</template>

<script>
import { getRiskDepartList } from "@/api/common";
export default {
  data() {
    return {
      list: [],
      result: "",
      loading: false,
      finished: false,
      filter: {
        page: 0,
        showMyDept: false,
        onlyMyDept: false,
        accounted: true,
        orgType: "D",
      },
      activeNames: ["1"],
      border: false,
      value: "",
      radio: "",
    };
  },
  created() {
    this.getList();
  },
  methods: {
    handleChange(id) {
        const newData = this.list.filter(item => item.OrgCode === id)
        console.log('asdsadad',newData);
      //params传参 使用name
      this.$router.push({
        name: "EquipmentEdit",
        params: {
          departId: newData[0].OrgCode,
          departName:newData[0].OrgName
        },
      });
    },
    getList() {
      this.loading = true;
      getRiskDepartList(this.filter)
        .then((res) => {
          this.loading = false;
          this.list = res.data;
          this.finished = true
          //this.filter.page = res.data.PageIndex;
        })
        .catch((err) => {
          this.finished = true;
        });
    },

    // 文件页面
    goFile() {
      // this.$router.push('/CommonInfo/InfoDetail')
    },
    onSearch(val) {
      Toast(val);
    },
    onCancel() {
      Toast("");
    },
  },
};
</script>

<style lang="less" scoped>
.risk {
  height: 100vh;
  background-color: #e8f1f8;
  .info_search {
    padding: 10px;
    border-radius: 5px !important;
    .van-field__control {
      background-color: #ffffff !important;
    }
  }
}
.risk_item_radio {
  width: 100%;
  padding: 10px 20px;
  background-color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e8f1f8;
}
</style>
